
var tableData={
	tableName:"",
	 init : function() {
		//alert("获取表信息");
		tableData.tableName = getUrlParam("tableName");
		
		//$("#sql").val("select * from "+ tableData.tableName);
		//$("#sql").val("insert into 123(2222,333,11) values('2222','333','11') return *");
		$("#sql").val("select * from  "+tableData.tableName);
		tableData.getDatas();
    },
	
	getDatas:function(){
		var params = {
					"to":"sqlInterface",	
					"msgId":"executeSql",
					"msg":{
						"sql":$("#sql").val()
						}
					};
		
		$.post("/watchDog/database/handleManage.req",JSON.stringify(params),function(result){
			//alert(result);
			var data = $.parseJSON(result);   
			
			if(DealErrorInfo(data,'获取数据失败：')){	 
				$("#datas").html("");
				var fields = data.msg.fields;
				var html = "<tr>";
				for(var i=0;i<fields.length;i++)
				{
					html += "<td class='title'>" + fields[i] + "</td>";
				}
				html += "<td class='title'>操作</td></tr>";
				$("#datas").append(html);
				
				var datas = data.msg.datas;
				for(var i=0;i<datas.length;i++)
				{
					var fieldDatas = datas[i];
					
					html = "<tr>"
					for(var k=0;k<fieldDatas.length;k++)
					{
						html += "<td>" + fieldDatas[k] + "</td>";
					}
					html += "<td></td>"
					html += "</tr>";
					
					$("#datas").append(html);
				}
				
			}															   
		}).fail(function(){
			$("#datas").html("连接服务器失败");
		});
	},
}